<%-- 
    Document   : DisplayListCar
    Created on : Oct 29, 2011, 12:13:20 AM
    Author     : MrKoi
--%>

<%@page import="Entity.Etbl_Cars"%>
<%@page import="Business.Btbl_Cars"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%><center>
<span style="font-size: 23px;color: #343434">List Cars</span>
</center>
<table cellspacing="6">
    <%
        ArrayList<Etbl_Cars> arrLstCar=(ArrayList<Etbl_Cars>)session.getAttribute("arrLstCar");      
        int totalPage=Integer.parseInt(session.getAttribute("TotalPage").toString());
    %>
    <%
    int i;
    int j;
    try{
    for(i=0;i< arrLstCar.size();i++){
       %>
    <tr><%
    if(arrLstCar.size()<3){
             for(j=0;j<arrLstCar.size();j++){    
        %>
        <td style="background:#f7f6f6;margin:6px;" align="center">
            <img src="Images/26_d3 2.jpg" width="150" style="padding: 5px; border-color: #3333ff;border-width: thin"/><br>
            car name: <%=arrLstCar.get(i).getName()%><br>
            So cho ngoi: 4<br>
            Price: 80$/day<br>
            <a href="#">Details</a> | <a href="#">Rental</a>
            
            </td>
        <%
        i++;
     }
         }else{
        
             for(j=0;j<3;j++){    
        %>
        <td style="background:#f7f6f6;margin:6px;" align="center">
            <img src="Images/26_d3 2.jpg" width="150" style="padding: 5px; border-color: #3333ff;border-width: thin"/><br>
            car name: <%=arrLstCar.get(i).getName()%><br>
            So cho ngoi: 4<br>
            Price: 80$/day<br>
            <a href="#" class="links">Details</a> | <a href="#" class="links">Rental</a>
            
            </td>
        <%
        i++;
     }
        
 }%>
    </tr>
    <%
    i--;}
    }catch(Exception e){
        
    }

%>             
</table>
<br>
    <%
        int pageIndex;        
        try{
            pageIndex=Integer.parseInt(session.getAttribute("PaingIndex").toString());
        }catch(Exception e){
            pageIndex=1;
        }
        if(pageIndex==0){
            pageIndex=1;
        }
        if(pageIndex>totalPage){
            pageIndex=totalPage;
    }
%>
<center>
    
    <%
    if(pageIndex<2){

%>
    <a href="DisplayCar?PaingIndex=<%=(pageIndex)%>"><%=(pageIndex)%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex+1)%>"><%=(pageIndex+1)%></a> | <a href="DisplayCar?PaingIndex=<%=pageIndex+2%>"><%=pageIndex+2%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex+3)%>"><%=(pageIndex+3)%></a> | <a href="DisplayCar?PaingIndex=<%=totalPage%>">Last</a></center>
    <%
    }else if(pageIndex==2){
    %>
    
    <a href="DisplayCar?PaingIndex=<%=(pageIndex-1)%>"><%=(pageIndex-1)%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex)%>"><%=(pageIndex)%></a> | <a href="DisplayCar?PaingIndex=<%=pageIndex+1%>"><%=pageIndex+1%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex+2)%>"><%=(pageIndex+2)%></a> | <a href="DisplayCar?PaingIndex=<%=totalPage%>">Last</a></center>
    
<%
   }else{
            
            if(pageIndex==totalPage){
            
%>    
        <a href="DisplayCar?PaingIndex=1">First</a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex-3)%>"><%=(pageIndex-3)%></a> | <a href="DisplayCar?PaingIndex=<%=pageIndex-2%>"><%=pageIndex-2%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex-1)%>"><%=(pageIndex-1)%></a> | <a href="DisplayCar?PaingIndex=<%=totalPage%>"><%=totalPage%></a></center>
<%
    }else{ 
            %>

<a href="DisplayCar?PaingIndex=1">First</a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex-1)%>"><%=(pageIndex-1)%></a> | <a href="DisplayCar?PaingIndex=<%=pageIndex%>"><%=pageIndex%></a> | <a href="DisplayCar?PaingIndex=<%=(pageIndex+1)%>"><%=(pageIndex+1)%></a> | <a href="DisplayCar?PaingIndex=<%=totalPage%>">Last</a></center>
<%
   }}
%>